import { ref } from 'vue'
import { userApi } from '@/api/user'

const useVideoList = () => {
  // 作品列表
  const postList = ref({
    videos: [],
    total: 0,
  })
  // 收藏列表
  const collectList = ref({
    collects: [],
    total: 0,
  })
  // 喜欢列表
  const likeList = ref({
    likes: [],
    total: 0,
  })
  const getPostList = async (id) => {
    const res = await userApi.getUserPosts(id)
    postList.value = res
  }
  const getCollectList = async (id) => {
    const res = await userApi.getUserCollects(id)
    collectList.value = res
  }
  const getLikeList = async (id) => {
    const res = await userApi.getUserLikes(id)
    likeList.value = res
  }
  const fetchList = async (id) => {
    await Promise.all([getPostList(id), getCollectList(id), getLikeList(id)])
  }
  return {
    postList,
    collectList,
    likeList,
    fetchList,
  }
}
export default useVideoList
